package cn.edu.cqut.mdm.core;

import java.io.IOException;
import java.util.Properties;

public class GlobalConfigManager {
	private static GlobalConfigManager globalConfigManager = new GlobalConfigManager();
	
	public static final String MODULE_INITIALIZE_INTERCEPTORS = "ModuleInitializeInterceptors";
	public static final String PUBLISHER_DISPATCHERS = "PublisherDispatchers";
	public static final String SERVERS = "Servers";
	public static final String USERS = "Users";
	
	private String CONFIG_FILE_NAME = "mdm.properties";
	private Properties properties = null;
	private boolean isLoaded = false;
	
	public static GlobalConfigManager getInstance() {
		return globalConfigManager;
	}
	
	public String get(String name) {
		if(!isLoaded){
			try {
				properties = new Properties();
				properties.load(Thread.currentThread().getContextClassLoader().getResourceAsStream(CONFIG_FILE_NAME));
				isLoaded = true;
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return properties.getProperty(name);
	}
}
